package org.funtester.performance.books.chapter01.section4;

/**
 * 优先级任务抽象类
 */
public abstract class PriorityRunnable implements Comparable<PriorityRunnable>, Runnable {

    int priorityLevel;// 优先等级，值越小优先级越高，用于优先级队列排序

    public PriorityRunnable(int priorityLevel) {
        this.priorityLevel = priorityLevel;
    }

    /**
     * 用与比较两个对象的优先级
     *
     * @param o
     * @return
     */
    @Override
    public int compareTo(PriorityRunnable o) {
        return this.priorityLevel - o.priorityLevel;
    }

}
